import { createStore } from 'vuex'
import persistedState from 'vuex-persistedstate'
const store = createStore({
  state:{
   
      zhanghui:[{username:'huang',password:'123456'}],
      count: 0,
      gaoliang:1,
      user:[],
      username:'',
      zhucheyem:false,
      apprrr:false,
    
  },
  // 直接修改state里面的数据源
  mutations: {
    gaiapprrr(state,val){
      state.apprrr=val
    },
    increment(state) {
      state.count++
      // console.log(state.count);
    },
    tianjiazhanghui(state,val) {
      
      state.zhanghui.unshift(val)
      // console.log(val);
    },
    gaolioangfangfa(state,val){
      state.gaoliang=val
    },
    datauser(state,val){
      // console.log('sotre',val);
      state.user=val
    },
    datausernamer(state,val){
      // console.log(val);
      state.username=val
    },
    shanchuzhanghui(state,val){
      state.zhanghui=val
    }
   
  },
  
// 用于异步函数(比如定时器延时器)修改修改数据
  actions: {
    incrementAsync(context) {
      setTimeout(() => {
        context.commit('increment')
      }, 1000)
    }
  },
  // 计算属性，相当于computed
  getters: {

  },
  plugins: [persistedState()]
})

export default store
